#pragma once

#include "StompCommand.h"

#define DEST_CardInfo		0
#define DEST_Auction		1
#define DEST_BidCaptcha		2
#define DEST_BidUpdate		3
#define DEST_Error			4
#define DEST_Message		5
#define DEST_AuctionID		6
#define DEST_MyBid			7
#define DEST_Captcha		8
#define DEST_Bid			9
#define DESTINATION_NUM		10

class CH5DestinationParser : public IDestinationParser
{
public:
	CH5DestinationParser();
	virtual ~CH5DestinationParser();
	virtual void clear();
	virtual void OnStompSubscribe(LPCSTR id, intptr_t destination);
	__forceinline LPCSTR getSubparam(intptr_t destination) const 
	{
		return destination >= 0 && destination < DESTINATION_NUM ? subparam[destination] : nullptr;
	}
	__forceinline LPCSTR getSubid(intptr_t destination) const
	{
		return destination >= 0 && destination < DESTINATION_NUM ? subid[destination] : nullptr;
	}
	__forceinline bool isSubscribe(intptr_t destination, LPCSTR param = nullptr) const
	{
		return destination >= 0 && destination < DESTINATION_NUM && (subscribe&(1 << destination)) != 0 &&
			(!param || (subparam[destination] && strcmp(param, subparam[destination]) == 0));
	}

	intptr_t prase_destination(LPCSTR dest, bool sub/*true-subscribe false-send*/) override;
	std::string destination_string(intptr_t destination) override;
	intptr_t prase_destination_fromid(LPCSTR id) override;
protected:
	uint32_t subscribe;
	LPCSTR subid[DESTINATION_NUM], subparam[DESTINATION_NUM];
};

typedef struct _stH5Destination
{
	LPCSTR subName;
	LPWSTR showName;
	bool haveParam, isSubscribe;
} stH5Destination;

extern const stH5Destination Destinations[DESTINATION_NUM];
